package com.huangxt.test;

import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

/**
 * Created by HXT on 2019/7/31.
 * 泛型
 */
public class GenericParadigm {
    public static void main(String[] args){
        List list = new ArrayList<>();
        for (int i = 0; i < 50; i++) {
            list.add(new RunnableTest1(i+1));
        }
        genericParadigm(list);
    }
    public static void genericParadigm(List<? extends Runnable> list){
        ExecutorService executorService = Executors.newFixedThreadPool(20);
        /**
         *  Executors.newFixedThreadPool
         *  Executors.newCachedThreadPool
         *  Executors.newSingleThreadExecutor
         *  Executors.newScheduledThreadPool
         */
        for (int i = 0; i < list.size(); i++) {
            executorService.execute(list.get(i));
        }
        System.out.println("-------------");
        executorService.shutdown();
    }
}
